<?php 
$start = 0;
$offset = 20;
?>
<script>

function failure(message){
	box_failure = new LightFace({ 
			title: 'Failure', 
			width : 300,
			content: "<div class='failure'>"+message+"</div>"
			,
			buttons: [{ title: 'Cancel', event: function() { this.close();}, color: 'green'}]
		});
		box_failure.open();		
}
function box_message(titleMessage,message){
	box_message = new LightFace({ 
			title: titleMessage, 
			width : 300,
			content: "<div class='message'>"+message+"</div>"
			,
			buttons: [{ title: 'Cancel', event: function() { this.close();}, color: 'blue'}]
		});
		box_message.open();		
}
//---------------------------------------------------------------------------------------------------->>>> page

var limit = {
	start : parseInt(0)	
}

function next(val){
	var perpage = {
			page : parseInt($(document.forms['viewperpage']).perpage.value)
		}
	var temp = {
			src : $(document.forms['search']).src.value
		}
	var source,next;
	source = limit.start;
	limit.start = source+perpage.page;
	var myRequest = new Request({
		url: '<?php echo site_url(array('just4u','help_show')) ?>'+'/'+limit.start+'/'+perpage.page+'/'+temp.src,
		method: 'post',
		onSuccess : function(responseText){
			$('showContent').fade('hide');
			$('showContent').fade(1);
			$('showContent').innerHTML = responseText;
		}
	}).send();
}

function prev(){
	var perpage = {
			page : parseInt($(document.forms['viewperpage']).perpage.value)
		}
	var temp = {
			src : $(document.forms['search']).src.value
		}
	var source,next;
	source = limit.start;
	if(source>=perpage.page){
		limit.start = source-perpage.page;
		var myRequest = new Request({
			url: '<?php echo site_url(array('just4u','help_show')) ?>'+'/'+limit.start+'/'+perpage.page+'/'+temp.src,
			method: 'post',
			onSuccess : function(responseText){
				$('showContent').fade('hide');
				$('showContent').fade(1);
				$('showContent').innerHTML = responseText;
			}
		}).send();
	} else {
		return false;
	}
}

//---------------------------------------------------------------------------------------------------->>>> Unas
function showContent(){
	var temp = {
		src : $(document.forms['search']).src.value
		
	}
	var perpage = {
		page : parseInt($(document.forms['viewperpage']).perpage.value)
	}	
	var myRequest = new Request({
		url: '<?php echo site_url(array('just4u','help_show')) ?>'+'/'+limit.start+'/'+perpage.page+'/'+temp.src,
		method: 'post',
		onSuccess : function(responseText){
			$('showContent').fade('hide');
			$('showContent').fade(1);
			$('showContent').innerHTML = responseText;
		}
	}).send();
}
function delhelp(form, evt, val){
	var msg = "";
	new Event(evt).stop();
	form = $(form);
		form.set('send', {
			url:'<?php echo site_url(array('just4u','help_delete'))?>'+'/'+val,
			method :'post',
		 	onSuccess: function(responseText, responseXML){	
			 	box_delete.close();
			 	showContent();
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				var message = "Failed to Delete";
				failure(message);
			}
		});
		form.send();
	return false;
}
function delete_help(val){
	box_delete = new LightFace({
		buttons: [
			{ title: 'Delete', event: function() { delhelp(this, event, val); }, color: 'green' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Delete',
		content: 'Are you sure you want to DELETE this file'
	}).open();
}
//---------------------------------------------------------------------------------------------------->>>> search
function search_pages(form, evt){
	var perpage = {
			page : parseInt($(document.forms['viewperpage']).perpage.value)
		}
	new Event(evt).stop();
	var temp = {
		src : $(document.forms['search']).src.value
	}
	form = $(form);
		form.set('send', {
			url:'<?php echo site_url(array('just4u','help_show')) ?>'+'/'+limit.start+'/'+perpage.page+'/'+temp.src,
			method :'post',
		 	onSuccess: function(responseText, responseXML){
				showContent();
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				alert("failure");
			}
		});
		form.send();
	return false;
}

//---------------------------------------------------------------------------------------------------->>>> formcheck
window.addEvent('load',function(){
	showContent();
});
</script>
<div align="center">
  <table width="100%" border="0" cellpadding="3" cellspacing="2">
  	<tr>
     <td width="68%" align="left" valign="middle" id="unas">
     <form method="post" enctype="multipart/form-data" onSubmit="search_pages(this, event)" name="search" id="search">
       Search :
       <input name="src" type="text" id="src" size="30">
       <input type="submit" name="button" id="button" value="Search" class="uiButtonRounded">
     </form>
     </td>
     <td align="right" id="unas">
       <form method="post" enctype="multipart/form-data" onKeyUp="showContent()" name="viewperpage" id="viewperpage">
         View per-page : 
         <label for="perpage"></label>
         <input name="perpage" type="text" id="perpage" size="1" maxlength="2" value="10">
      </form></td>
      <td width="6%" align="right"><a class="uiButtonRounded" href="javascript: prev()"><b><</b></a> <a class="uiButtonRounded" href="javascript: next()"><b>></b></a>&nbsp;</td>
    </tr>
    <tr align="center">
     <td colspan="3">
        <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tbody id="showContent"></tbody>
        </table>
     </td>
    </tr>
    <tr>
     <td height="30" colspan="3" align="right" id="unas"><a class="uiButtonRounded" href="javascript: prev()"><b><</b></a> <a class="uiButtonRounded" href="javascript: next()"><b>></b></a>&nbsp;</td>
    </tr>
  </table>
</div>
